package com.husd.framework.ddl_new;

/**
 * @author shengdonghu@126.com
 * @date 2024/1/22 17:42
 */
public class WordStringScanner {

    private String str;

    private int index = 0; // 当前索引
    private int len = 0;

    public WordStringScanner(String str) {
        this.str = str;
        this.len = this.str.length();
    }

    public char current() {

        if (index >= len) {
            throw new RuntimeException("无效的index:" + index);
        }
        return str.charAt(index);
    }

    public boolean haveC() {

        return index <= this.len - 1;
    }

    public boolean haveNext() {

        return index <= this.len - 2;
    }

    public boolean next() {
        boolean c = haveNext();
        this.index++;
        return c;
    }
}
